#include <vector>
#include <fstream>
#include <filesystem>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <array>
#include <string>
#include <cstring>
#include <iterator>
#include <math.h>
// #include <int8_t.h>


#pragma once
class Tensor {
public:
	Tensor() = default;
	Tensor(const std::shared_ptr<int8_t[]>& data, const std::vector<int>& dims) : data_(data), dims_(dims) {}


	Tensor(const std::vector<int8_t>& data, const std::vector<int>& dims) : data_(std::shared_ptr<int8_t[]>(new int8_t[data.size()])),
		dims_(dims) {
		std::copy_n(data.begin(), data.size(), (int8_t*)data_.get());
	}

	auto data() const { return data_; }
	static Tensor fromFtmpFile(const std::string& ftmp_file, const std::vector<int>& ftmp_dims);
	const std::vector<int>& dims() const { return dims_; }
	int size() const {
		return std::accumulate(dims_.begin(), dims_.end(), (int)!dims_.empty(), std::multiplies<int>());
	}
	void outFile(const std::string out_dir) const;
//	Tensor InitInput(const std::vector<int>& ftmp_dims);

private:
	std::shared_ptr<int8_t[]> data_;
	std::vector<int> dims_;
};